import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/screenLayout'
import Home from '@/mapLayout'
import Home2 from '@/mapLayout/index2'
import DMap from '@/3DMapLayout'
export const constantRoutes = [
    {
        path: '/',
        component: Home
    },
    {
        path: '/index2',
        component: Home2
    },
    {
        path: '/3d',
        component: DMap
    },
    {
        path: '/caseAnalysis',
        component: (resolve) => require(['@/caseAnalysis/index'], resolve),
        name: 'caseAnalysis',
        meta: { title: '大屏', }
    },
    // 大屏菜单
    // { 
    //     path: '/',
    //     component: Layout,
    //     redirect: '/load',
    //     children: [
    //       {
    //         path: '/server',
    //         component: (resolve) => require(['@/screenLayout/server'], resolve),
    //         name: 'Server',
    //         meta: { title: '服务水平',}
    //       },
    //       {
    //         path: '/load',
    //         component: (resolve) => require(['@/screenLayout/load'], resolve),
    //         name: 'Load',
    //         meta: { title: '业务承载',}
    //       },{
    //         path: '/effect',
    //         component: (resolve) => require(['@/screenLayout/effect'], resolve),
    //         name: 'Effect',
    //         meta: { title: '业务效能',}
    //       },
    //       {
    //         path: '/check',
    //         component: (resolve) => require(['@/screenLayout/check'], resolve),
    //         name: 'Check',
    //         meta: { title: '巡检督查',}
    //       },
    //       {
    //         path: '/prevent',
    //         component: (resolve) => require(['@/screenLayout/prevent'], resolve),
    //         name: 'Prevent',
    //         meta: { title: '风险防控',}
    //       },
    //       {
    //         path: '/business',
    //         component: (resolve) => require(['@/screenLayout/business'], resolve),
    //         name: 'Business',
    //         meta: { title: '业务承载',}
    //       },
    //     ]
    //   },
    {
        path: '*',
        redirect: '/',
        hidden: true
    }
]


export const asyncRoutes = [

]

const createRouter = () => new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({
        y: 0
    }),
    routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router
